<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
	$enterptiseType = $_POST["EnterpriseType"];
	$businessValue = $_POST["BusinessValue"];
	$documentsNumber = $_POST["DocumentsNumber"];
	$domain = $_POST["Domain"];
	$services = $_POST["Services"];
	$employee = $_POST["Employee"];
	$calculateTariff = $_POST["CalculateTariff"];
	
	$calculateBilant = $_POST["CalculateBilant"];
	if (!is_null($calculateBilant))
	{
		$bilantServiceType = $_POST["BilantServiceType"];
		$bilantValue = $_POST["BilantValue"];		
		
		$isValidForm = true;
		if (is_null($bilantServiceType) || !is_numeric($bilantServiceType))
		{
			$isValidForm = false;
			$bilantServiceTypeError = "Va rugam alegeti tipul de bilant";
		}
		if (is_null($bilantValue) || !is_numeric($bilantValue) || $bilantValue < 0)
		{
			$isValidForm = false;
			$bilantValueError = "Va rugam alegeti valoarea bilantului";
		}
		
		if ($isValidForm)
		{
			$totalAmount = 0;
		
			if ($bilantValue >= 0 && $bilantValue <= 10000)
				$totalAmount = 100;
			else if ($bilantValue >= 10001 && $bilantValue <= 44000)
				$totalAmount = 150;
			else if ($bilantValue >= 44001 && $bilantValue <= 88000)
				$totalAmount = 150 + 0.00175 * ($bilantValue - 44001);
			else if ($bilantValue >= 88001 && $bilantValue <= 176000)
				$totalAmount = 220 + 0.000875 * ($bilantValue - 88001);
			else if ($bilantValue >= 176001 && $bilantValue <= 440000)
				$totalAmount = 300 + 0.0005 * ($bilantValue - 176001);
			else if ($bilantValue >= 440001 && $bilantValue <= 880000)
				$totalAmount = 420 + 0.0003 * ($bilantValue - 440001);
			else if ($bilantValue >= 880001 && $bilantValue <= 1759000)
				$totalAmount = 550 + 0.0002 * ($bilantValue - 880001);
			else if ($bilantValue >= 1759001 && $bilantValue <= 4398000)
				$totalAmount = 700+0.000175 * ($bilantValue - 1759001);
			else if ($bilantValue >= 4398001 && $bilantValue <= 8796000)
				$totalAmount = 900 + 0.00004 * ($bilantValue - 4398001);
			else if ($bilantValue >= 8796000)
				$totalAmount = 1120 + 0.00003 * ($bilantValue - 8796000);
				
			if ($bilantServiceType == 2)
				$totalAmount = $totalAmount * 1.5;
				
			$totalAmount = ceil($totalAmount);

			$last = $totalAmount % 10;
			if($last != 0)
				$totalAmount = $totalAmount + (10 - $last);

			$bilantMessage = "Suma estimariva pentru calcul bilant: ".$totalAmount." RON";	
		}
	}
	
	
	if (!is_null($calculateTariff))
	{
		$isValidForm = true;
		
		if (is_null($enterptiseType) || !is_numeric($enterptiseType) || $enterptiseType == -1)
		{
			$isValidForm = false;
			$enterptiseTypeError = "Va rugam alegeti forma juridica";
		}
		if (is_null($businessValue) || !is_numeric($businessValue) || $businessValue < 0)
		{
			$isValidForm = false;
			$businessValueError = "Va rugam alegeti cifra de afaceri";
		}
		if (is_null($documentsNumber) || !is_numeric($documentsNumber) || $documentsNumber < 0)
		{
			$isValidForm = false;
			$documentsNumberError = "Va rugam alegeti Inregistrari contabile";
		}
		if (is_null($domain) || !is_numeric($domain) || $domain == -1)
		{
			$isValidForm = false;
			$domainError = "Va rugam alegeti Domeniu de activitate";
		}
		if (is_null($services) || !is_numeric($services) || $services == -1)
		{
			$isValidForm = false;
			$servicesError = "Va rugam alegeti Servicii de contabilitate";
		}
		if (is_null($employee) || !is_numeric($employee) || $employee < 0)
		{
			$isValidForm = false;
			$employeeError = "Va rugam alegeti Numar salariati";
		}		
		
		if ($isValidForm)
		{
			$totalAmount = 0;
		
			$businessValueAmount = 0;
			if ($businessValue >= 0 && $businessValue <= 5000)
				$businessValueAmount = 100;
			else if ($businessValue >= 5001 && $businessValue <= 15000)
				$businessValueAmount = 150 + 0.005 * ($businessValue - 5001);
			else if ($businessValue >= 15001 && $businessValue <= 53000)
				$businessValueAmount = 225 + 0.004 * ($businessValue - 15001);
			else if ($businessValue >= 53001 && $businessValue <= 105000)
				$businessValueAmount = 400 + 0.0035 * ($businessValue - 53001);
			else if ($businessValue >= 105001 && $businessValue <= 211000)
				$businessValueAmount = 600 + 0.0017 * ($businessValue - 105001);
			else if ($businessValue >= 211001 && $businessValue <= 880000)
				$businessValueAmount = 800 + 0.0003 * ($businessValue - 211001);
			else if ($businessValue >= 880001)
				$businessValueAmount = 1000 + 0.0002 * ($businessValue - 211001);
			
			$documentsNumberAmount = 0;
			if ($documentsNumber >= 0 && $documentsNumber <= 50)
				$documentsNumberAmount = 50;
			else if ($documentsNumber >= 51 && $documentsNumber <= 100)
				$documentsNumberAmount = 150;
			else if ($documentsNumber >= 101 && $documentsNumber <= 200)
				$documentsNumberAmount = 250;
			else if ($documentsNumber >= 201 && $documentsNumber <= 300)
				$documentsNumberAmount = 400;
			else if ($documentsNumber >= 301 && $documentsNumber <= 400)
				$documentsNumberAmount = 550;
			else if ($documentsNumber >= 401)
				$documentsNumberAmount = 700 + 0.5 * ($documentsNumber - 400);
	
			$domainAmount = 0;
			switch ($domain)
			{
				case 1: 
					$domainAmount = 1;
				break;
				case 2: 
					$domainAmount = 1.1;
				break;
				case 3: 
					$domainAmount = 1.3;
				break;
				case 4: 
					$domainAmount = 0.75;
				break;
			}
	
			$servicesAmount = 0;
			switch ($services)
			{
				case 1: 
					$servicesAmount = 0;
				break;
				case 2: 
					$servicesAmount = 1;
				break;
				case 3: 
					$servicesAmount = 0.5;
				break;
				case 4: 
					$servicesAmount = 0.5;
				break;
				case 5: 
					$servicesAmount = 0.25;
				break;
				case 6: 
					$servicesAmount = 0.25;
				break;
			}
			
			$employeeAmount = $employee * 10;
			
			$enterpriseAmount = 0;
			switch ($enterptiseType)
			{
				case 1: 
					$enterpriseAmount = 1;
				break;
				case 2: 
					$enterpriseAmount = 1.5;
				break;
				case 3: 
					$enterpriseAmount = 0.5;
				break;
				case 4: 
					$enterpriseAmount = 0.5;
				break;
				case 5: 
					$enterpriseAmount = 0.75;
				break;
			}
			
			$totalAmount = (((($businessValueAmount + $documentsNumberAmount + $employeeAmount) * $enterpriseAmount) * $domainAmount) * 1.1);
			if ($servicesAmount == 0)
				$totalAmount = $totalAmount + 150;
			else	
				$totalAmount = $totalAmount * $servicesAmount;
	
			if ($totalAmount < 150)
				$totalAmount = 150;
			
			$totalAmount = ceil($totalAmount);

			$last = $totalAmount % 10;
			if($last != 0)
				$totalAmount = $totalAmount + (10 - $last);

			$evidentaMessage = "Suma estimariva pentru evidenta contabila: ".$totalAmount." RON";	
		}
	}

	if (!is_null())
	{
		$to = $_REQUEST["EmailAddress"];
		$subject = "Aritax Consulting, Certificare 2010 - Declaratia 101";
		$msg = file_get_contents("Oferta.htm", true);
	
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$headers .= "From: adriana.popa@aritax.ro \r\n";
		$headers .= "Reply-To: adriana.popa@aritax.ro \r\n";	
	
		try
		{
			if (strlen($to) > 0)
				mail($to, $subject, $msg, $headers);
		}
		catch (Exception $exception)
		{
			
		}
	}	
?>

<body>
<form id="form1" name="form1" method="post" action="">
  <div><strong>Tarif evidenta contabila - orientativ</strong></div>
  <br />
  <table width="400" border="0" cellspacing="5" cellpadding="4">
    <tr>
      <td>Forma juridica:</td>
      <td><select name="EnterpriseType" id="EnterpriseType">
          <option value="-1" <?php echo $enterptiseType == -1 ? "selected" : ""; ?>>Alegeti forma juridica</option>
          <option value="1" <?php echo $enterptiseType == 1 ? "selected" : ""; ?>>S.R.L.</option>
          <option value="2" <?php echo $enterptiseType == 2 ? "selected" : ""; ?>>S.A.</option>
          <option value="3" <?php echo $enterptiseType == 3 ? "selected" : ""; ?>>P.F.A.</option>
          <option value="4" <?php echo $enterptiseType == 4 ? "selected" : ""; ?>>O.N.G.</option>
          <option value="5" <?php echo $enterptiseType == 5 ? "selected" : ""; ?>>Altele</option>
        </select></td>
    </tr>
    <tr>
      <td>Cifra de afaceri:</td>
      <td><input type="text" name="BusinessValue" value="<?php echo $businessValue; ?>"/></td>
    </tr>
    <tr>
      <td>Inregistrari contabile<br />/volum documente:</td>
      <td><input type="text" name="DocumentsNumber" value="<?php echo $documentsNumber; ?>" /></td>
    </tr>
    <tr>
      <td>Domeniu de activitate:</td>
      <td><select name="Domain" id="Domain">
          <option value="-1" <?php echo $domain == -1 ? "selected" : ""; ?>>Alegeti domeniul de activitate</option>
          <option value="1" <?php echo $domain == 1 ? "selected" : ""; ?>>prestari serviicii</option>
          <option value="2" <?php echo $domain == 2 ? "selected" : ""; ?>>comert</option>
          <option value="3" <?php echo $domain == 3 ? "selected" : ""; ?>>productie</option>
          <option value="4" <?php echo $domain == 4 ? "selected" : ""; ?>>non-profit</option>
        </select></td>
    </tr>
    <tr>
      <td>Servicii de contabilitate:</td>
      <td><select name="Services" id="Services">
          <option value="-1" <?php echo $services == -1 ? "selected" : ""; ?>>Alegeti serviciile dorite</option>
          <option value="1" <?php echo $services == 1 ? "selected" : ""; ?>>fara activitate</option>
          <option value="2" <?php echo $services == 2 ? "selected" : ""; ?>>completa</option>
          <option value="3" <?php echo $services == 3 ? "selected" : ""; ?>>primara</option>
          <option value="4" <?php echo $services == 4 ? "selected" : ""; ?>>financiara</option>
          <option value="5" <?php echo $services == 5 ? "selected" : ""; ?>>declaratii fiscale</option>
          <option value="6" <?php echo $services == 6 ? "selected" : ""; ?>>salarii</option>                    
        </select></td>
    </tr>
    <tr>
      <td>Numar salariati:</td>
      <td><input type="text" name="Employee" value="<?php echo $employee; ?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="CalculateTariff" type="submit" value="CalculateTariff" /></td>
    </tr>
  </table>

  <div><strong>Tarif Tarif bilant - orientativ</strong></div>
  <br />
  <table width="500" border="0" cellspacing="5" cellpadding="4">
    <tr>
      <td>Alegeti tipul de servicii:</td>
      <td><input name="BilantServiceType" type="radio" value="1" <?php echo $bilantServiceType == 1 ? "checked='checked'" : "" ?>>verificare si certificare</input> <br />
	      <input name="BilantServiceType" type="radio" value="2" <?php echo $bilantServiceType == 2 ? "checked='checked'" : "" ?>>intocmire si certificare</input> 
      </td>
    </tr>
    <tr>
      <td>Valoarea bruta a conturilor din balanta:</td>
      <td><input type="text" name="BilantValue" value="<?php echo $bilantValue; ?>"/></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="CalculateBilant" type="submit" value="CalculateBilant" /></td>
    </tr>
  </table>
</form>

</body>

</html>